<?php

namespace App\Controllers\Home;

use App\Controllers\Controller;
use App\Facades\Db;
use App\Utils\QRcode;
use App\Utils\RandNumImage;
use App\Utils\UploadFile;
use App\Logics\UploadsLogic;

class DataController extends Controller
{

    public function initProduct()
    {
        $res = Db::table('product')->find(3);
        //print_r($res);exit;
        $dataList = [];
        for($i=2; $i<18; $i++){
            $dataList[] = [
                'class_id' => $res['class_id'],
                'title' => $res['title'] . $i,
                'cover' => $res['cover'],
                'content' => $res['content'],
                'seo_title' => $res['seo_title'] . $i,
                'created_at' => now(),
                'updated_at' => now(),
            ];
        }
        //print_r($dataList);exit;
        Db::table('product')->batchInsert($dataList);
        //print_r($res);
    }

    public function initArticle() {
        $res = Db::table('article')->find(25);
        //print_r($res);exit;
        $dataList = [];
        for($i=2; $i<=4; $i++){
            $dataList[] = [
                'class_id' => $res['class_id'],
                'title' => $res['title'] . $i,
                'cover' => $res['cover'],
                'content' => $res['content'],
                'seo_title' => $res['seo_title'] . $i,
                'created_at' => now(),
                'updated_at' => now(),
            ];
        }
        //print_r($dataList);exit;
        Db::table('article')->batchInsert($dataList);
    }

}